import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useDictStore = defineStore('sv-dict', () => {
  const dict = ref({}) // 私有，不做return

  function setDict(name, data) {
    dict.value[name] = data
  }

  function getDict(name) {
    return dict.value[name]
  }

  function deleteDict(name) {
    delete dict.value[name]
  }

  function clearDict() {
    dict.value = {}
  }

  return {
    setDict,
    getDict,
    deleteDict,
    clearDict
  }
})
